/********************************************************
 *  ██████╗  ██████╗████████╗██╗
 * ██╔════╝ ██╔════╝╚══██╔══╝██║
 * ██║  ███╗██║        ██║   ██║
 * ██║   ██║██║        ██║   ██║
 * ╚██████╔╝╚██████╗   ██║   ███████╗
 *  ╚═════╝  ╚═════╝   ╚═╝   ╚══════╝
 * Geophysical Computational Tools & Library (GCTL)
 *
 * Copyright (c) 2023  Yi Zhang (yizhang-geo@zju.edu.cn)
 *
 * GCTL is distributed under a dual licensing scheme. You can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation, either version 2 
 * of the License, or (at your option) any later version. You should have 
 * received a copy of the GNU Lesser General Public License along with this 
 * program. If not, see <http://www.gnu.org/licenses/>.
 * 
 * If the terms and conditions of the LGPL v.2. would prevent you from using 
 * the GCTL, please consider the option to obtain a commercial license for a 
 * fee. These licenses are offered by the GCTL's original author. As a rule, 
 * licenses are provided "as-is", unlimited in time for a one time fee. Please 
 * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget 
 * to include some description of your company and the realm of its activities. 
 * Also add information on how to contact you by electronic and paper mail.
 ******************************************************/

#ifndef _GAUSSFUNC_H
#define _GAUSSFUNC_H

#include "../core/enum.h"
#include "../core/macro.h"

#include "cmath"
#include "exception"
#include "stdexcept"

namespace gctl
{
    /**
     * @brief      一维高斯分布参数
     */
    struct gaussian_para1d
    {
        double mu; ///< 分布中心
        double sigma; ///< 分布标准差
        gaussian_para1d();
        gaussian_para1d(double in_mu, double in_sigma);
    };

    //正态函数参数组
    struct gaussian_para2d
    {
        // 中心位置x y 标准差位置半径x y 绕x轴逆时针旋转的弧度
        double mu_x, mu_y, sigma_x, sigma_y, rho;
        gaussian_para2d();
        gaussian_para2d(double in_mux, double in_muy, double in_sigmax, 
            double in_sigmay, double in_rho);
    };

    /**
     * @brief      一维高斯分布值
     *
     * @param[in]  para  高斯分布参数
     * @param[in]  x     采样位置
     *
     * @return     采样位置的概率值
     */
    double gaussian_dist1d(double x, const gaussian_para1d &para, gradient_type_e mode = Value);

    /**
     * @brief      二维高斯分布，返回坐标位置的数值
     *
     * @param[in]  x     x坐标
     * @param[in]  y     y坐标
     * @param[in]  p     高斯分布参数
     * @param[in]  mode  计算模式(Value为分布值，Dx为x方向梯度，Dy为y方向梯度)
     *
     * @return     坐标位置的数值
     */
    double gaussian_dist2d(double x, double y, const gaussian_para2d &p, 
        gradient_type_e mode = Value);
}

#endif // _GAUSSFUNC_H